import axios from 'axios'
import { config } from 'vue/types/umd'

const sevice =axios.create({
    respoonseType:'arraybuffer'
})

sevice.interceptors.request.use(config =>{
    config.headers['Authorization'] = window.sessionStorage.getItem('tokenStr')
    return config
}, error =>{
    console.log(error);
})


sevice.interceptors.response.use( resp =>{
    const headers = resp.headers
    //政策表达式
    let rege = RegExp(/application\/json/)
    if(headers['content-type'].match(reg)){
        resp.data = unitToString(resp.data)
    }else{
        let fileDownload = require('js-file-download')
        let fileName = headers['content-disposition'].split(";")[1]
        let contentType = headers['content-type']

    }
},error =>{

})

let base =''
export const downloadRequest =(url,params) =>{
    return service({
        method:'get',
        url:`${base}${url}`,
        data:params
    })
}
export default service